package com.yunxi.controller.dealer;

import com.alibaba.dubbo.config.annotation.Reference;
import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.CurrentUser;
import com.yunxi.core.web.LoginInfo;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.dealer.pojo.BusinessVO;
import com.yunxi.dealer.pojo.PartnerStorageVO;
import com.yunxi.dealer.service.PartnerStorageDubboService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 渠道商仓库地址 前端控制器
 * </p>
 *
 * @author
 * @since 2019-05-14
 */
@RestController
@RequestMapping("/admin/partner/partnerstorage")
@Api(tags = "partner:partnerstorage", description = "渠道商仓库地址接口")
public class PartnerStorageController {
   private static final Logger logger = LoggerFactory.getLogger(PartnerStorageController.class);

   //   @Reference(version = "${demo.service.version}",
//           application = "${dubbo.application.id}",
//           url = "${dubbo.application.url}",
//           check = false,
//           timeout = 10000)
   @Autowired
   PartnerStorageDubboService partnerStorageDubboService;

   @GetMapping("/list")
   @ApiOperation(value = "查询列表")
   public ApiResult list(PartnerStorageVO v) throws Exception {
      return ResponseUtil.ok(partnerStorageDubboService.listByVo(v));
   }

   @GetMapping("/page")
   @ApiOperation(value = "查询分页")
   public ApiResult page(PartnerStorageVO partnerStorageVO, Integer pageNum, Integer pageSize) throws Exception {
      return ResponseUtil.ok(partnerStorageDubboService.findPageByVO(partnerStorageVO, pageNum, pageSize));
   }

   @GetMapping("/load")
   @ApiOperation(value = "读取单个")
   public ApiResult load(PartnerStorageVO partnerStorageVO, @CurrentUser LoginInfo loginInfo) throws Exception {
      return ResponseUtil.ok(partnerStorageDubboService.getById(partnerStorageVO.getStorageId()));
   }

   @PostMapping("/save")
   @ApiOperation(value = "保存信息")
   public ApiResult save(@RequestBody PartnerStorageVO partnerStorageVO, @CurrentUser LoginInfo loginInfo) throws Exception {
      partnerStorageDubboService.saveOrUpdate(partnerStorageVO);
      return ResponseUtil.ok("success");
   }

   @GetMapping("/del")
   @ApiOperation(value = "删除")
   public ApiResult del(String storageId, String partnerCode, @CurrentUser LoginInfo loginInfo) throws Exception {
      partnerStorageDubboService.removeById(storageId, partnerCode, loginInfo);
      return ResponseUtil.ok("success");
   }

/*@PostMapping("/export")
@ApiOperation(value = "导出excel")
public Object export(@RequestParam Map<String,Object> params) throws Exception {
return ResponseUtil.ok(partnerStorageDubboService.findMapByList(params));
}*/
}
